import java.util.Scanner;

//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int x = scanner.nextInt();
        int count =0;
        for(int i=1;i<=n;i++)
        {
            int num = i;
            while (num>0)
            {
                int digit = num % 10;
                if (digit == x)
                {
                    count++;
                }
                num /= 10;
            }
        }
        System.out.println(count);
    }
}